<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('articles', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('key')->nullable()->comment('seo路由');
            $table->unsignedInteger('category_id')->default('0')->comment('模块id，0新闻');
            $table->string('title')->nullable()->comment('标题');
            $table->string('picture')->nullable()->comment('图片');
            $table->text('content')->nullable()->comment('内容');
            $table->unsignedInteger('sort')->nullable()->comment('排序值');
            $table->tinyInteger('state')->default('0')->nullable()->comment('状态：0草稿，1发布，-1下线');
            $table->unsignedInteger('views')->default('0')->nullable()->comment('浏览次数');
            $table->unsignedInteger('likes')->default('0')->nullable()->comment('点赞次数');
            $table->text('seo')->nullable()->comment('seo信息tdk');
            $table->integer('admin_id')->nullable()->comment('管理员ID');
            $table->dateTime('publish_at')->nullable()->comment('发布时间');
            $table->timestamps();
            $table->softDeletes();
        });


        Schema::create('article_category', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('pid')->default('0')->nullable()->comment('父级id');
            $table->string('name')->nullable()->comment('分类名');
            $table->integer('order')->default('0')->nullable()->comment('排序值');
            $table->tinyInteger('display')->nullable()->comment('显示状态');
            $table->unsignedTinyInteger('state')->default('0')->nullable()->comment('可用状态');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('articles');
        Schema::dropIfExists('article_category');
    }
};
